package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleService;
import com.heima.common.commons.ArticleConstants;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
public class ArticleController {
    @Autowired
    ApArticleService apArticleService;
    @PostMapping("/load")
    public ResponseResult  load(@RequestBody ArticleHomeDto articleHomeDto){
//        ResponseResult responseResult = apArticleService.loadArticleList(articleHomeDto, ArticleConstants.LOADTYPE_LOAD_MORE);
        ResponseResult responseResult = apArticleService.load2(articleHomeDto, ArticleConstants.LOADTYPE_LOAD_MORE, true);
        return responseResult;
    }
    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto articleHomeDto){
        ResponseResult responseResult = apArticleService.loadArticleList(articleHomeDto, ArticleConstants.LOADTYPE_LOAD_MORE);
        return responseResult;
    }
    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto articleHomeDto){
        ResponseResult responseResult = apArticleService.load2(articleHomeDto, ArticleConstants.LOADTYPE_LOAD_NEW,false);
        return responseResult;
    }
}
